package com.cy.zs.hp.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cy.zs.hp.mapper.HisPatientMapper;
import com.cy.zs.hp.model.HisPatient;
import com.cy.zs.hp.service.IHisPatientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 该表为患者表，当患者预约挂号时使用此表 服务实现类
 * </p>
 *
 * @author cgb2008
 * @since 2020-11-28
 */
@Service
public class HisPatientServiceImpl extends ServiceImpl<HisPatientMapper, HisPatient> implements IHisPatientService {
    @Autowired
    private HisPatientMapper hisPatientMapper;




    @Override
    public int insertPatient(HisPatient hisPatient) {
        String phone =hisPatient.getPhone();
     List<HisPatient> list=hisPatientMapper.findPatient(phone);
        if (list.size()!=0){
            int rows=hisPatientMapper.deletePatient(phone);
            System.out.println("rows>>>>>>>>"+rows);
        }

        return hisPatientMapper.insertPatient(hisPatient);
    }

    @Override
    public List<HisPatient> findPatient(String phone) {

        return hisPatientMapper.findPatient(phone);
    }

}
